﻿@model Free2AskWeb.Models.QuestionModel

@{
    ViewBag.Title = "Details";
}

@section Styles {
    <link href="@Url.Content("~/Content/Details.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/showgraybg.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/tag.css")" rel="stylesheet" type="text/css" />
}

@section JavaScript{
    <script type="text/javascript" src="../Content/tinymce/tinymce.min.js"></script>
    <script type="text/javascript">
        tinyMCE.init({
            mode: "textareas",
            encoding: "xml"
        });
    </script>
    <script type="text/javascript" src="@Url.Content("/Scripts/Details.js")"></script>
    @*<script type ="text/javascript" src="@Url.Content("/Scripts/jquery.unobtrusive-ajax.js")"></script>*@
}

@section subnav{<div id="title"><h2>@Model.Question.Title</h2></div>}


<dl id="postContainer">
    <dt id="status">
          <div><span class="plus" id="@Model.Question.ID"></span></div>
          <div id='vote@(Model.Question.ID)'>@Model.Question.Votes.Sum(v=>v.Value)</div>
          <div><span class="minus" id="@Model.Question.ID"></span></div>
    </dt>
    <dd>
          <div id="postText">@Html.Raw(Model.Question.PostContent)</div>
          <div id="tags">
              @Html.Label("Tags: ")
              @foreach (var tag in Model.Question.Tags)
              {
                  <span class="txtTag">@Html.Label(tag.Name)</span>
              }
          </div>
          <div id="author">@if(Model.Question.Author!=null){<h3>@Model.Question.Author.UserName</h3>} Author Info
            @foreach (var feedback in Model.Question.Feedbacks)
            {
                <p>@feedback.FeedbackContent</p><br />
            }
            @if(Model.Question.Author!=null&&Model.Question.Author.UserName==User.Identity.Name||User.IsInRole("admin"))
            {
                @Html.ActionLink("Modify","Modify",new {PostID=Model.Question.ID},null)
            }
          </div>
    </dd>
</dl>

<div id="answerCount"><h3>@Model.Answers.Count.ToString() Answers</h3></div>
@foreach (var answer in Model.Answers)
{
    <dl id="postContainer" class="seperator">
        <dt id="status">
          <div><span class="plus" id="@answer.ID"></span></div>
          <div id='vote@(answer.ID)'>@answer.Votes.Sum(v=>v.Value)</div>
          <div><span class="minus" id="@answer.ID"></span></div>
        </dt>
        <dd>
          <div id="postText">@Html.Raw(answer.PostContent)</div>
          <div id="author">@if(answer.Author!=null){<h3>@answer.Author.UserName</h3>}<p>Author Info</p>
          @if (ViewBag.AuthorID == answer.AuthorID || User.IsInRole("admin"))
              {
                  @Html.ActionLink("Modify","Modify",new {PostID=answer.ID},null)
              }  
          </div>
        </dd>
    </dl>
}
<div id="yourAnswer">
<h3>Your Answer</h3>
@using (Html.BeginForm("PostAnswer", "Answer",FormMethod.Post, new { id="answerForm"}))
{
    @Html.Hidden("QuestionID",Model.Question.ID) 
    @*@Html.TextArea("PostContent")*@
    @Html.RichTextareaFor("PostContent")
    <div style="clear:both"></div>
    <input type="submit" value="Post Your Answer" class="creat" />
}
</div>


@section rightColumn{
            @Html.Partial("_TagListView",Model.Question.Tags)
}



   
